<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'list.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" href="<%=request.getContextPath() %>/resources/validform/css/demo.css" type="text/css"></link>
<link rel="stylesheet" href="<%=request.getContextPath() %>/resources/validform/css/style.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/jquery-1.9.1.min.js"></script>

  </head>
  
  <body>
    <form  id="myForm" name="myForm"  action="<%=request.getContextPath() %>/indeximg!updateIndeximg.action" suc_url="<%=request.getContextPath() %>/indeximg!sreachIndeximg.action" class="myform"  enctype="multipart/form-data">
	<input name="id" type="hidden"  value="${request.resultMap.info.id }">
		<br /> <br /> <br /> <br />
		<center>
			<table width="850" height="210px" border="0">

				<tr>
					<td width="254" rowspan="5">
						<div id="localImag">
							<img id="preview" src="<%=request.getContextPath() %>/uploadFiles/${request.resultMap.info.murl}" width="230px" height="200px" style="diplay:none;" />
						</div>
					</td>
					<td class="need" style="width:10px;">*</td>
					<td style="width:80px;">标题：</td>
					<td style="width:205px;">
						<input type="text" value="${request.resultMap.info.title}" name="title" class="inputxt" datatype="*1-18" errormsg="最多18个字符！" />
					</td>
					<td>
						<div class="Validform_checktip">标题为1~18个字符</div>
					</td>
				</tr>
				<tr>
					<td class="need" style="width:10px;">*</td>
					<td style="width:80px;">昵称：</td>
					<td style="width:205px;">
						<input type="text" value="${request.resultMap.info.mname}" name="mname" class="inputxt" datatype="*1-18" errormsg="最多18个字符！" />
					</td>
					<td>
						<div class="Validform_checktip">昵称为1~18个字符</div>
					</td>
				</tr>
				<tr>
					<td class="need" style="width:10px;">*</td>
					<td style="width:80px;">图片：</td>
					<td style="width:205px;">
						<input class="inputxt" type="file" name="upload" onchange="javascript:setImagePreview();"	 id="doc">
					</td>
					<td>
						<div class="Validform_checktip">昵称为6~18个字符</div>
					</td>
				</tr>
				<tr>
					<td class="need">*</td>
					<td>排序：</td>
					<td>
						<input type="text" name="orderid" value="${request.resultMap.info.orderid}" class="inputxt" datatype="n" errormsg="请输入数字排序" />
					</td>
					<td><div class="Validform_checktip"></div></td>
				</tr>
				<tr>
					<td class="need">*</td>
					<td>是否启用：</td>
					<td>
						<input type="radio" value="1" name="sfqy" id="male" class="pr1"
							<c:if test="${requestScope.resultMap.info.sfqy==1}">
								checked='checked' 
							</c:if> />
							<label>是</label>
						<input type="radio" value="0" name="sfqy" id="female" class="pr1"
							<c:if test="${requestScope.resultMap.info.sfqy==0}"> 
								checked='checked' 
							</c:if> />
							<label>否</label>
					</td>
					<td><div class="Validform_checktip"></div></td>
				</tr>
				<tr>
					 <td colspan="5" align="center"><input type="submit" value="提交"/></td>
				</tr>
			</table>
				
		</center>


	</form>
  </body>
  <script type="text/javascript"  src="<%=request.getContextPath() %>/resources/js/jquery.form.js"></script>
 <script type="text/javascript"  src="<%=request.getContextPath() %>/resources/validform/js/Validform_v5.3.2.js"></script>
 <script type="text/javascript"  src="<%=request.getContextPath() %>/resources/js/common.js"></script>
 <script type="text/javascript"  src="<%=request.getContextPath() %>/resources/js/opform.js"></script>
<script type="text/javascript">
  	function setImagePreview() { 
			var docObj=document.getElementById("doc"); 
			var imgObjPreview=document.getElementById("preview"); 
			if(docObj.files && docObj.files[0]){ 
			//火狐下，直接设img属性 
			imgObjPreview.style.display = 'block'; 
			imgObjPreview.style.width = '230px'; 
			imgObjPreview.style.height = '200px'; 
			//imgObjPreview.src = docObj.files[0].getAsDataURL(); 
			//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式 
			imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]); 
			
			}else{ 
			//IE下，使用滤镜 
			docObj.select(); 
			var imgSrc = document.selection.createRange().text; 
			var localImagId = document.getElementById("localImag"); 
			//必须设置初始大小 
			localImagId.style.width = "230px"; 
			localImagId.style.height = "200px"; 
			localImagId.style.position = "absolute"; 
			
			//图片异常的捕捉，防止用户修改后缀来伪造图片 
			try{ 
			localImagId.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)"; 
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc; 
			}catch(e){ 
			alert("您上传的图片格式不正确，请重新选择!"); 
			return false; 
			} 
			imgObjPreview.style.display = 'none'; 
			document.selection.empty(); 
			} 
			return true; 
		}
	 $(function () {
		  $(".myForm").Validform({
			tiptype:function(msg,o,cssctl){
				if(!o.obj.is("form")){
					var objtip=o.obj.parents("td").next().find(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			usePlugin:{
				jqtransform:{}
			}
	});});
  </script>
</html>
